<template>
  <!-- 房管设置 -->
  <div class="app-container">
    <reservation-list-container
      :searchItems="searchItems"
      :actionButtons="actionButtons"
      :tableData="tableData"
      :columns="columns"
      :loading="loading"
      :total="1000"
      :showResetButton="false"
      @search="handleSearch"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      @sort-change="handleSortChange"
    >
      <template #status="{ row }">
        <span :style="{ color: row.status === 0 ? '#f56c6c' : '#606266' }">
          {{ row.status === 0 ? "移除" : "添加" }}
        </span>
      </template>
    </reservation-list-container>
    <AddManager ref="addManagerRef" />
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import AddManager from "./components/AddManager.vue";
import ReservationListContainer from "@/components/PageTable/ReservationList.vue";

const addManagerRef = ref();

// 搜索项配置
const searchItems = [
  {
    label: "用户",
    prop: "name",
    component: "el-input",
    props: {
      placeholder: "请输入标题",
    },
  },
];

// 操作按钮配置
const actionButtons = [
  {
    text: "新增房管",
    handler: () => {
      addManagerRef.value.show();
    },
    type: "primary" as "primary",
    icon: undefined,
    loading: false,
  },
];

// 表格列配置
const columns = [
  {
    prop: "name",
    label: "用户昵称",
  },
  {
    prop: "time",
    label: "添加时间",
  },
  {
    label: "状态",
    slot: "status",
  },
];

// 表格数据
const tableData = ref([
  {
    index: 1,
    status: 0,
    name: "名称",
    time: "2025-02-18 15:00:00",
  },
]);

const loading = ref(false);

// 搜索方法
const handleSearch = (searchData: any) => {
  console.log("搜索操作", searchData);
};

// 分页大小变化方法
const handleSizeChange = (size: any) => {
  console.log("分页大小变化", size);
};

// 当前页变化方法
const handleCurrentChange = (page: any) => {
  console.log("当前页变化", page);
};

// 排序变化方法
const handleSortChange = (sortInfo: any) => {
  console.log("排序变化", sortInfo);
};
</script>
<style lang="scss" scoped></style>
